package com.leisure.utils;

/**
 * ClassName: ThreadLocalUtil
 * Package: com.leisure.utils
 * Description: 本地线程变量
 *
 * @Author: MyLeisureLife
 * @Date: 2024/6/12:08:12:27 星期三
 */
public class ThreadLocalUtil {
    public static final ThreadLocal<Object> THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 获取THREAD_LOCAL里面存储的对象
     * @return 对象
     * @param <T> 类型
     */
    public static <T> T get(){
        return (T)THREAD_LOCAL.get();
    }

    /**
     * 存储对象
     * @param object 对象
     */
    public static void set(Object object){
        THREAD_LOCAL.set(object);
    }

    /**
     * 清楚THREAD_LOCAL 防止内存泄漏
     */
    public static void remove(){
        THREAD_LOCAL.remove();
    }



}
